package com.tencent.yolov8ncnn;

import android.os.Environment;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author xuyan QQ:1213236113
 * @name yolov8ncnn
 * @class name：com.tencent.yolov8ncnn
 * @class describe
 * @time 2024/8/18 19:19
 */
class FileDir {

   public static final String FILE_DIR = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()+"/yolov8ncnn/";
   public static final String LOG_FILE_NAME = "log.txt";
   public static String getDir(){
      File dirFile = new File(FILE_DIR);
      if (!dirFile.exists()) {
         dirFile.mkdirs();
      }
      return FILE_DIR;
   }

   public static String getTimeDir(){
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
      String formattedDate = sdf.format(new Date(System.currentTimeMillis()));
      String fileDir = getDir() +formattedDate+"/";
      File dirFile = new File(fileDir);
      dirFile.mkdirs();
      return fileDir;
   }

   public static String getLogPath(String dir){
      File file = new File(dir+LOG_FILE_NAME);
      if (!file.getParentFile().exists()) {
         file.getParentFile().mkdirs();
      }
      return file.getPath();
   }

}
